<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>offsetParent</title>
<style>
#div1{width: 200px;height: 200px;background: #ccc;margin: 100px;position: relative;}
#div2{width: 100px;height: 100px;background: #f00; position: absolute;left: 50px;top: 50px;}
</style>
<script type="text/javascript">
    window.onload=function(){
        var oDiv2=document.getElementById('div2');
        alert(oDiv2.offsetParent);
    };
</script>    
</head>
<body>
    <div id="div1">
        <div id="div2"></div>
    </div>
</body>
</html>